<template>
  <div style="height: 100%;background-color:white ;padding: 5px">
    <div>
      <div style="display: inline-block"> <el-button size="small" icon="el-icon-back" type="text" @click="goBack">返回</el-button></div>
      <div style="display: inline-block">|</div>
      <div style="display: inline-block;">
        <div style="padding-bottom: 15px;margin-left:10px">
          <span style=" font-family: 'Microsoft YaHei',serif;display: inline-block">推送日志</span>
        </div>
      </div>
      <div style="border-bottom: solid 1px #C9C9C9;"></div>
    </div>
    <div style="margin-top: 10px">
      <label> 知识名称: <span v-html="$route.query.knowledgeName"></span></label>

    </div>
    <el-row>
      <el-table highlight-current-row :data="syncLogTableData.slice((currentPage-1)*pageSize,currentPage*pageSize)" border
                style="width: 100%;margin-top: 10px" stripe max-height="500">
        <el-table-column label="知识版本" prop="version"></el-table-column>
        <el-table-column label="操作人" prop="operatedBy"></el-table-column>
        <el-table-column label="推送平台" prop="platformName"></el-table-column>
        <el-table-column label="推送状态" prop="syncFlag">
          <template slot-scope="scope">
            <span v-if="scope.row.syncFlag">推送成功</span>
            <span v-else style="color: red">推送失败</span>
          </template>
        </el-table-column>
        <el-table-column label="记录时间" prop="operatedTime" :formatter="dateFormat">
        </el-table-column>
      </el-table>
    </el-row>
    <el-row>
      <el-pagination :total="syncLogTableData.length"
                     :current-page.sync="currentPage"
                     :page-size="pageSize"
                     background
                     layout="prev, pager, next"
                     style="text-align: center;"/>
    </el-row>
  </div>
</template>

<script>
import moment from "moment";

export default {
  data() {
    return {
      syncLogTableData: [],
      currentPage: 1,
      pageSize: 10
    }
  },
  methods: {
    goBack: function () {
      this.$router.go(-1)
          },
        dateFormat: function (row, column) {
          const date = row[column.property]
          if (date == undefined) {
            return ''
          }
          return moment(date).format("YYYY-MM-DD  HH:mm:ss")
        },
        getSyncLogTableData(){
          var that = this
          this.axios.get('/pmph/action/knowledgeLib/selectSyncLogTableData', {
            params: {
              id:this.$route.query.id
            }
          }).then((response) => {
            console.log(response)
            this.syncLogTableData = response.data;
          }).catch((error) => {
            console.error(error);
            this.syncLogTableData = [];
            this.$message.error("未能请求到数据");
          })
        }
      },
      created() {
        this.getSyncLogTableData();
      }
    }


</script>

<style scoped>

</style>
